<?php namespace Admin\Controller;
use Hdphp\Controller\Controller;
//登录控制器
class LoginController extends Controller{
	public function index(){
		if(IS_POST){
			//用户名和密码的判断
			//获取用户名密码
			$username = Q('post.username');
			$password = Q('post.password','','md5');
			//查询用户信息
			$model = new \Admin\Model\User;
			$userData = $model->where(array('adminname'=>$username))->find();
			if(!$userData){
				View::error('用户名或密码错误，请重新输入');
			}
			//用户名判断正确后判断密码是否正确
			if($userData['adminpwd'] != $password){
				View::error('用户名或密码错误，请重新输入');
			}
			$_SESSION['info'] = array(
				'aid' => $userData['aid'],
				'username' => $userData['adminname'],
				'adminaccount' => $userData['adminaccount']
			);
			View::success('登录成功',U('Index/index'));
		}
	    View::make();
	}
	//退出
	public function out(){
		session_unset();
		session_destroy();
		go(U('Login/index'));
	}
}




 ?>